package aop;

import entity.Equip;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.Arrays;

@Component("loggerAspect")
@Aspect
public class LoggerAspect {
    private static final Logger logger = LoggerFactory.getLogger(LoggerAspect.class);

    @Before(value = "execution(*.* service..insert(entity.Equip))")
    public void before(JoinPoint jp){
        // 获取方法参数
        Equip equip= (Equip) jp.getArgs()[0];
        if(equip.getType().equals("指环")){
            equip.setType(equip.getName());
            equip.setName("紫色梦幻"+equip.getName());
            equip.setAttackPlus(equip.getAttackPlus()+6);
            equip.setDefencePlus(equip.getDefencePlus()+6);
        }
    }
}
